<template>
	<h1>注册</h1>
	<hr>
	<button @click="routerBack">返回</button>
	<p> <input type="text" v-model="userForms.username" /></p>
	<p> <input type="text" v-model="userForms.password" /></p>
	<p> <input type="text" v-model="userForms.vercode" /></p>
	<button @click="sendSms">{{tipMsg}}</button>
	<button @click="reg">注册</button>
	<p>
	</p>
</template>
<script setup>
	import {
		ref,
		reactive,
		onMounted
	} from 'vue';


	import {
		regApi
	} from '@/api/user.js'
	import router from '@/router'


	import useSendSms from '../useSendSms.js';
	import {
		showToast
	} from 'vant';


	const userForms = reactive({
		username: '',
		password: '',
		vercode: '',
	})

	const {
		sendSms,
		tipMsg
	} = useSendSms(userForms, "register")


	function reg() {

		console.log(userForms)
		regApi(userForms).then(res => {
			console.log(res)

			if (res.code == 0) {

				showToast(res.msg)

				setTimeout(v => {

					router.back()
				}, 1000)

			} else {

				showToast(res.msg)
			}
		})
	}
</script>
<style>
	@import url('../user.css');
</style>